/**
 * @Controller 分享目标地址
 */
const Controller = require('egg').Controller;

class TargetsController extends Controller {

    /**
     * @Router POST /api/v1/templates
     * @Request body createTargetsRequest createTargetsRequest 创建目标链接
     * @Request header string authorization
     * @Response 200 baseResponse 响应
     * @Summary 创建目标链接
     */
    async create() {
        const ctx = this.ctx;
        ctx.validate(ctx.rule.createTargetsRequest, ctx.body);
        const data = {
            ...ctx.request.body,
            creator: ctx.state.user.id
        }
        try {
            const newTargets = await ctx.service.target.createTarget(data);
            ctx.body = {
                code: 200,
                data: newTargets,
                success: true,
                msg: ``
            };
        }
        catch (err) {
            throw err;
        }

    }

}

module.exports = TargetsController;